CXX=g++
CXXFLAGS=-w -std=c++11 -g
target=main

# 查找当前目录下的所有.c文件
src = $(wildcard ./src/main/*.cpp ./src/util/logger/*.cpp )
$(info $(src))
# 查找所有.c文件对应的.o文件，如果不存在则根据模式匹配规则生成
obj = $(patsubst %.cpp, %.o, $(src))
$(info $(obj))

include=-I./  \
		-I./src  \
		-I./src/thirdpkg/include \
		-I./src/util/logger \

lib=-L./src/thirdpkg/lib/log4cpp -llog4cpp \
	-Wl,-rpath=./src/thirdpkg/lib/log4cpp \
	-lpthread \
	

$(target): $(obj)
	$(CXX) $(obj) -o $(target) $(lib) ${CXXFLAGS}
	mv ${target} ./bin/
	mkdir -p log
	rm -rf ${obj} 

%.o: %.cpp
	$(CXX) ${include} -c $< -o $@ ${CXXFLAGS}

# 删除中间文件和可执行文件
clean:
	rm -rf $(obj) $(target)

run:${target}
	./bin/$(target)